home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / lib / mntc6846.zoo / patch / xmul.s < prev    next >
Encoding:
Text File  |  1994-10-17  |  818 b   |  44 lines

  1. *
  2. *  c68 support routines .Xlmul, .Xulmul, .Xaslmul, .Xasulmul
  3. *
  4. *  multiplication of signed and unsigned long quantities
  5. *  (based on a routine used by SozobonX's xdlibs library)
  6. *
  7.     .text
  8.  
  9.     .globl    .Xlmul
  10.     .globl    .Xulmul
  11.     .globl    .Xaslmul
  12.     .globl    .Xasulmul
  13.  
  14. .Xaslmul:
  15. .Xasulmul:
  16.     movem.l    4(sp),d1/a1
  17.     exg    d1,a1
  18.     move.l    (a1),d0
  19.     bsr    Rlmul
  20.     move.l    d0,(a1)        ; assign result
  21.     bra    fin
  22.  
  23. .Xlmul:
  24. .Xulmul:
  25.     movem.l    4(sp),d0/d1    ; get operands
  26.     bsr    Rlmul
  27. fin:    move.l    (sp)+,a0    ; get return address
  28.     addq.l    #8,sp        ; remove two long parameters
  29.     jmp    (a0)        ; return to calling code
  30.  
  31. Rlmul:    move.l    d0,d2        ; do the actual multiplication
  32.     mulu    d1,d2        ; (this code is identical for both
  33.     movea.l    d2,a0        ; unsigned and signed longs)
  34.     move.l    d0,d2
  35.     swap    d0
  36.     mulu    d1,d0
  37.     swap    d1
  38.     mulu    d2,d1
  39.     add.l    d1,d0
  40.     swap    d0
  41.     clr.w    d0
  42.     add.l    a0,d0
  43.     rts
  44.